package com.xqls.biz.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xqls.bean.FluggasVocRecordBean;
import com.xqls.biz.FluggasVocRecordBiz;
import com.xqls.dal.model.FluggasVocRecord;
import com.xqls.service.FluggasVocRecordService;
import com.xqls.util.CommonPage;
import com.xqls.util.CommonResult;
import com.xqls.util.ObjectUtil;
import com.xqls.util.VelocityUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Service
public class FluggasVocRecordBizImpl implements FluggasVocRecordBiz {

	private static Logger logger = Logger.getLogger(FluggasVocRecordBiz.class);
	
	@Autowired private FluggasVocRecordService recordService;
	
	@Override
	public CommonResult insertRealdata(FluggasVocRecordBean recordBean) {
		CommonResult result = new CommonResult();
		FluggasVocRecord record=null;
		try {
			record=(FluggasVocRecord) ObjectUtil.transfer(recordBean, FluggasVocRecordBean.class);
			result.setIsSuccess(this.recordService.insertRealdata(record));
		} catch (Exception e) {
			logger.error("voc记录插入异常！", e);
		}
		return result;
	}

	@Override
	public CommonResult getListByPage(CommonPage commonPage, HttpServletRequest request, HttpServletResponse response) {
		CommonResult result = new CommonResult();
		try {
			commonPage.setPageData(this.recordService.getListByMap(commonPage.pageToMap()));
			Map<String,Object> showMap=new HashMap<String,Object>();
			showMap.put("vocRecordList",commonPage.getPageData());
			commonPage.setHtml(VelocityUtil.getHtmlByMap("fluggas/vocRecordListData.vm",showMap,request,response,request.getSession().getServletContext()));
			result.setIsSuccess(true);
		} catch (Exception e) {
			logger.error("voc记录查询异常！", e);
		}
		return result;
	}

	@Override
	public FluggasVocRecordBean getByDeviceNo(String deviceNo) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Map<String, Object>> getAll() {
		// TODO Auto-generated method stub
		return null;
	}

}
